//
//  BPLabel.swift
//  BPWeiBo
//
//  Created by 扒皮大叔 on 16/4/11.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

//class BPLabel: UILabel {
//}

//自定义UIlabel的构造方法
extension UILabel {
    convenience init(text: String,textColor: UIColor,fontSize: CGFloat,margin: CGFloat = 0) {
        
        self.init()
        self.text = text
        self.textColor = textColor
        self.font = UIFont.systemFontOfSize(fontSize)
        
        self.numberOfLines = 0
        //设置居中
        self.textAlignment = .Center
        //设置最大显示的宽度
        if margin > 0 {
            preferredMaxLayoutWidth = ScreenWidth - 2*margin
            textAlignment = .Left
        }
    
        self.sizeToFit()
        
    }
    
}